package backtrack_Recursion;

import java.util.*;

public class QuestionOne {
    static class Pao{
        int x;
        int y;
        int id;

        public Pao(int x, int y, int id) {
            this.x = x;
            this.y = y;
            this.id = id;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        Pao[] paos = new Pao[n];

        Map<Integer, List<Pao>> rows = new HashMap<>();
        Map<Integer, List<Pao>> cols = new HashMap<>();

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            paos[i] = new Pao(x,y, i);
            rows.computeIfAbsent(x,k -> new ArrayList<>()).add(paos[i]);
            cols.computeIfAbsent(y,k -> new ArrayList<>()).add(paos[i]);
        }
        int[] res = new int[n];
        //zuoyou
        for(List<Pao> list : rows.values()){
            list.sort(Comparator.comparingInt(c -> c.y));
            int sz = list.size();
            Map<Integer, Integer> yToIdx = new HashMap<>();
            for (int i = 0; i < sz; i++) {
                yToIdx.put(list.get(i).id, i);
            }
            for (int i = 0; i < sz; i++) {
                Pao cur = list.get(i);
                // 左
                if(i >= 2) res[cur.id]++;
                // you
                if(i + 2 < sz) res[cur.id]++;
            }
        }
        //shangxia
        for(List<Pao> list : cols.values()){
            list.sort(Comparator.comparingInt(c -> c.x));
            int sz = list.size();
            Map<Integer, Integer> xToIdx = new HashMap<>();
            for (int i = 0; i < sz; i++) {
                xToIdx.put(list.get(i).id, i);
            }
            for (int i = 0; i < sz; i++) {
                // 左
                if(i >= 2) res[list.get(i).id]++;
                // you
                if(i + 2 < sz) res[list.get(i).id]++;
            }
        }
        for (int cnt : res) {
            System.out.println(cnt);
        }

    }
}
